package com.itbaizhan.test.exercise;

/**
 * String
 */
public class StringTest3 {
    public static void main(String[] args) {
        String s1 = "core java";
        String s2 = "Core java";
        System.out.println(s1.charAt(3));//提取下标为3的字符，由0开始数起
        System.out.println(s2.length());//字符串长度  9  ,从o数起
        System.out.println(s1.equals(s2));//比较两个字符串是否相等  大小写 false
        System.out.println(s1.equalsIgnoreCase(s2));//字符串s1中是否包含Java
        System.out.println(s1.indexOf("java"));//字符串s1中是否包含Java
        System.out.println(s1.indexOf("apple"));//字符串s1中是否包含apple  没找到 -1

        String s3 ="I love java.java is best.Who is study java";
        System.out.println(s3.indexOf("java"));
        System.out.println(s3.lastIndexOf("java"));
        //返回的是全新的字符串
        String s = s1.replace(' ','&' );   //将s1中的空格替换成&(' ','&')内
        System.out.println("result:" + s);


    }
}
